<template>
	<view class="container">
		<view class="wrapper">
			<view style="padding: 40rpx;">
				<view style="margin: 40rpx 0rpx;">
					<view style="display:flex;justify-items:center;align-items: center;">
						<image :src="userInfo.avatar?userInfo.avatar:'../../static/mine/user-circle-solid.png' " style="width: 120rpx;height:120rpx;border-radius: 120rpx;padding-right:30rpx;"></image>
						<view>
							<view style="font-size:34rpx;font-weight:600;color:#fffff1;line-height:60rpx;">
								{{ userInfo.realName || '' }}{{ (userInfo.identity == 2?'（场馆主）':userInfo.identity == 3?'（教练员）':userInfo.identity == 4?'（指导员）':userInfo.identity == 1?'':'（体检中心）') }}
							</view>
							<view style="font-size:26rpx;color: #e5e5e5;">
								 账号： {{ userInfo.account || '-'}}
							</view>
						</view>
					</view>
				</view>
				<view style="background-color: rgba(255, 255, 255, 75%);padding: 40rpx 10rpx 40rpx 10rpx;border-radius: 20rpx;">
					<view class="list">
						<view class="item" v-for="item in menuList" :key="item.name" @click="onHandle(item)">
							<image :src="item.icon"></image>
							<view class="name">{{item.name}}</view>
							<u-icon name="arrow-right" color="#999" size="20rpx">
							</u-icon>
							<button v-if="item.name === '一键分享'" open-type="share"></button>
						</view>
						<view class="item" v-if="venueIdentity == '7'" @click="onLink('/pages/index/venueBusiness')">
							<image src="/static/mine/icon_share.png"></image>
							<view class="name">切换场馆</view>
							<u-icon name="arrow-right" color="#999" size="20rpx"></u-icon>
						</view>
						<view class="item" @click="outLogin()">
							<image src="/static/image/venue.png"></image>
							<view class="name">退出登录</view>
							<u-icon name="arrow-right" color="#999" size="20rpx">
							</u-icon>
						</view>	
					</view>
					
				</view>	
			</view>
		</view>
	</view>
	
</template>

<script>
	import utils from '@/utils/utils.js';
	import md5 from '@/utils/md5.js';
	export default {
		data() {
			return {
				//7场馆主商家，多场馆
				venueIdentity: 0,
				userInfo: {
					//图片
					avatar: '',
					//真实名称
					realName: '',
					//账号
					account: '',
					//身份（1：普通用户，2：场馆主，3：教练员，4：指导员，5：体检中心，7：商户多场馆）
					identity: 0
				},
				menuList: [
					{
						icon: '/static/mine/icon_pwd.png',
						name: '密码设置'
					},
					// {
					// 	icon: '/static/mine/icon_share.png',
					// 	name: '一键分享'
					// },
					{
						icon: '/static/mine/icon_about.png',
						name: '关于我们'
					},
					{
						icon: '/static/mine/icon_help.png',
						name: '帮助中心'
					}
				]
			}
		},
		onShow() {
			var venueIdentity = uni.getStorageSync('venueIdentity');
			this.venueIdentity = venueIdentity;
			console.log("venueIdenewewtity",this.venueIdentity);
			
			this.getUserData();
		},
		methods: {
			//用户信息
			getUserData(){
				uni.showLoading({
					title: '加载中',
					mask: true
				})
				this.$request({
					url: `/blade-merchant-app/merchant-app/user/getUser`,
					type: 'GET'
				}).then(res => {
					uni.hideLoading();
					this.userInfo = {
						avatar: res.data.avatar,
						realName: res.data.realName,
						account: res.data.account,
						identity: res.data.identity
					}
				})
			},
			onLink(url) {
				uni.navigateTo({ url: url })
			},
			outLogin(){
				utils.onLogout();
			},
			// 操作
			onHandle(record) {
				switch (record.name) {
					case '密码设置':
						uni.navigateTo({
							url: '/pages/mine/updatePwd/updatePwd'
						})
						break;
					case '关于我们':
						uni.navigateTo({
							url: '/pagesBusiness/pages/about/about'
						})
						break;
					case '帮助中心':
						uni.navigateTo({
							url: '/pagesBusiness/pages/helpCenter/helpCenter'
						})
						break;		
			
					case '一键分享':
						uni.share({
							provider: "weixin",
							title: '全民运动商家端',
							scene: "WXSceneSession",
							type: 5,
							miniProgram: {
								id: 'wx8d604ce8eb0f3256',
								path: 'pages/home/index'
							},
							success: function(res) {
								console.log("success:" + JSON.stringify(res));
							},
							fail: function(err) {
								console.log("fail:" + JSON.stringify(err));
							}
						});
						break;
			
					default:
						uni.showToast({
							icon: 'none',
							title: '正在开发中',
							duration: 2000
						})
						break;
				}
			},
		}
	}
	
	
</script>

<style lang="scss">
	page {
		height: 100%;
		background: #ffffff;
		overflow: hidden;
		background: linear-gradient(#155CCF,#e5e5e5, #e5e5e5);
		letter-spacing: 1rpx;

		.container {
			height: 100%;

			.wrapper {
				width: 100%;
				
				
				.list {
				
					.item {
						position: relative;
						display: flex;
						flex-direction: row;
						align-items: center;
						padding: 32rpx 45rpx;
				
						image {
							display: block;
							width: 40rpx;
							height: 40rpx;
						}
				
						.name {
							flex: 1;
							padding-left: 20rpx;
							font-size: 31rpx;
						}
				
						button {
							position: absolute;
							top: 0;
							left: 0;
							width: 100%;
							height: 100%;
							background-color: transparent;
				
							&::after {
								border: none;
							}
						}
				
						&:nth-child(n + 2) {
							border-top: 1rpx solid #e6e6e6;
						}
					}
				}
			}
		}
	}			
	
</style>